<!--
 * @Author: byron
 * @Date: 2021-08-31 15:52:06
 * @LastEditTime: 2021-09-10 11:26:10
 * @Summary: 展开运算符复习
-->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        console.log('展开运算符复习');
        const arr1 = [1, 3, 5, 7, 9]
        const arr2 = [2, 4, 6, 8, 10]
        console.log(arr1);
        console.log(...arr1);
        arr3 = [...arr1, ...arr2]
        console.log(arr3);

        //接受不确定参数
        function sum(...number) {
            console.log('计算求和');
            console.log(number);
        }
        sum(1, 2)
        let obj1 = {
            name: '王灿',
            age: '18',
            sex: 'man',
        }
        console.log(obj1);
        //console.log(...obj1); 不能直接展开对象
        let obj2 = obj1 //直接赋值运算符是浅拷贝
        obj1.name = '李登惠子'
        console.log(obj2);
        console.log(obj1);

        //使用...运算符是深拷贝第一层，如果有嵌套的话还是浅拷贝，严格意义上还是浅拷贝
        obj3 = {
            ...obj1
        }
        obj1.name = 'geigei'
        console.log('obj3 使用...', obj3);
        console.log('obj1', obj1);
    </script>
</body>

</html>